/* 
 *	Copyright (C) 2009-2010 miaohua
 *	http://code.google.com/p/lrcshower/
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#pragma once

#include <vector>
#include "SongProp.h"

//Play mode
enum PlayMode{NO=0, SEQ=1, LOOP=2, RAND=4, LIST=8};
#define Remove_Seq_Mask      ~SEQ             // Remove SEQ flag 
#define Remove_Loop_Mask     ~LOOP            // Remove LOOP flag
#define Remove_Rand_Mask     ~RAND            // Remove RAND flag

// One play list
typedef std::vector<SongProp> PLSongList;

// Play list struct
struct OnePlayList
{
   OnePlayList():m_IsValidate(true), m_SelSongIdx(-1){}
   void GenRandIdx();
   int AddOneSong(const tstring & SongFullPath, int Pos);
   int MoveOneSong(int SrcIdx, int DstIdx);
   bool IsSongValidate(unsigned int SongIdx=-1)const;
   int GetIndex(unsigned int SongIdx=-1)const;
   REFERENCE_TIME GetDura(unsigned int SongIdx=-1)const;
   tstring GetNextProp(unsigned int SongIdx=-1);
   tstring GetLabel(unsigned int SongIdx=-1)const;
   tstring GetFullPath(unsigned int SongIdx=-1)const;
   tstring GetSongName(unsigned int SongIdx=-1)const;
   tstring GetSingerName(unsigned int SongIdx=-1)const;
   tstring GetSongTips(unsigned int SongIdx=-1)const;
   int GetPrevSongIdx(int PlayMode);
   int GetNextSongIdx(int PlayMode);
   void GetSongProp();
   int GetSelSongIdx()const;
   void SetSelSongIdx(int SongIdx);
   bool IsValidate()const{ return m_IsValidate; }
   void Invalidate(){ m_IsValidate = false; }
   unsigned int Size()const{ return m_SongList.size(); }
  
   tstring m_PLName;                            // Name of play list
   int m_SelSongIdx;                            // Current selected song's index in current play list
   bool m_IsValidate;                           // Wether the play list is validate
   PLSongList m_SongList;                       // Song list
   std::vector<int> m_RandList;                 // Play sequnce for song in random mode
   std::vector<int> m_RandIdxList;              // 
};

// Playlists
typedef std::vector<OnePlayList> PlayList;